﻿using System;

namespace diantou.web.ajax.admin
{
    /// <summary>
    /// 考试问题调用
    /// </summary>
    [fastCSharp.code.cSharp.ajax(IsPool = true)]
    class examQuestion : permissionHandle<examQuestion>
    {
        /// <summary>
        /// 添加考试问题
        /// </summary>
        /// <param name="value"></param>
        /// <param name="onReturn"></param>
        public void Append(diantou.examDataAccess.examQuestion value, Action<fastCSharp.net.returnValue<int>> onReturn)
        {
            if ((currentUser.Permission & dataModel.user.permission.ExamEditor) != 0)
            {
                value.UserId = currentUser.Id;
                diantou.examDataAccess.tcpCall.examQuestion.append(value, onReturn);
            }
            else onReturn(0);
        }
        /// <summary>
        /// 修改考试问题
        /// </summary>
        /// <param name="value"></param>
        /// <param name="onReturn"></param>
        public void Rework(diantou.examDataAccess.examQuestion value, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            if ((currentUser.Permission & dataModel.user.permission.ExamEditor) != 0) diantou.examDataAccess.tcpCall.examQuestion.rework(value, currentUser.Id, onReturn);
            else onReturn(false);
        }
        /// <summary>
        /// 发布考试问题
        /// </summary>
        /// <param name="id"></param>
        /// <param name="onReturn"></param>
        public void Show(int id, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            if (currentUser.Permission == dataModel.user.permission.Admin) diantou.examDataAccess.tcpCall.examQuestion.show(id, currentUser.Id, onReturn);
            else onReturn(false);
        }
        /// <summary>
        /// 考试问题过期
        /// </summary>
        /// <param name="id"></param>
        /// <param name="onReturn"></param>
        public void Expired(int id, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            if (currentUser.Permission == dataModel.user.permission.Admin) diantou.examDataAccess.tcpCall.examQuestion.expired(id, currentUser.Id, onReturn);
            else onReturn(false);
        }
        /// <summary>
        /// 考试问题过期
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="onReturn"></param>
        public void BatchExpired(int[] ids, Action<fastCSharp.net.returnValue<int[]>> onReturn)
        {
            if (currentUser.Permission == dataModel.user.permission.Admin) diantou.examDataAccess.tcpCall.examQuestion.expired(ids, currentUser.Id, onReturn);
            else onReturn(null);
        }
        /// <summary>
        /// 删除考试问题
        /// </summary>
        /// <param name="id"></param>
        /// <param name="onReturn"></param>
        public void Delete(int id, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            if (currentUser.Permission == dataModel.user.permission.Admin) diantou.examDataAccess.tcpCall.examQuestion.delete(id, currentUser.Id, onReturn);
            else onReturn(false);
        }
        /// <summary>
        /// 删除考试问题
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="onReturn"></param>
        public void BatchDelete(int[] ids, Action<fastCSharp.net.returnValue<int[]>> onReturn)
        {
            if (currentUser.Permission == dataModel.user.permission.Admin) diantou.examDataAccess.tcpCall.examQuestion.delete(ids, currentUser.Id, onReturn);
            else onReturn(null);
        }
        /// <summary>
        /// 发布考试问题
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="onReturn"></param>
        public void BatchShow(int[] ids, Action<fastCSharp.net.returnValue<int[]>> onReturn)
        {
            if (currentUser.Permission == dataModel.user.permission.Admin) diantou.examDataAccess.tcpCall.examQuestion.show(ids, currentUser.Id, onReturn);
            else onReturn(null);
        }
        /// <summary>
        /// 批量修改自动发布时间
        /// </summary>
        /// <param name="problemIds"></param>
        /// <param name="startTime"></param>
        public void BatchAutoShowTime(int[] ids, DateTime startTime, Action<fastCSharp.net.returnValue<int>> onReturn)
        {
            if (currentUser.Permission == dataModel.user.permission.Admin) diantou.examDataAccess.tcpCall.examQuestion.reworkAutoShowTime(ids, startTime, onReturn);
            else onReturn(0);
        }

    }
}
